package com.learning.spring.cloud.api;

import com.learning.spring.cloud.dto.CreateOrderResult;
import com.learning.spring.cloud.dto.OrderDto;
import com.learning.spring.cloud.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @PostMapping(path = "/create")
    public CreateOrderResult createOrder(@RequestBody OrderDto orderDto) {
        return orderService.createOrder(orderDto);
    }

    @PostMapping(path = "/find/{orderNo}")
    public OrderDto findByOrderNo(@PathVariable("orderNo") String orderNo) {
        return orderService.findByOrderNo(orderNo);
    }
}
